package thread;

public class DaemonThreadDemo {
    public static void main(String[] args) {
        Thread rose = new Thread(){
            @Override
            public void run() {
                for(int i=0;i<5;i++){
                    System.out.println("let go");
                    try {
                        Thread.sleep(1500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("rose:aaaaaaaaaaaaaa");
                System.out.println("噗通");
            }
        };
        Thread jock = new Thread(){
            @Override
            public void run() {
                while (true){
                    System.out.println("you go i go!");
                    try {
                        Thread.sleep(1500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        rose.start();
        jock.isDaemon();//将jock设置为守护线程，普通线程结束，直接将守护线程kill掉
        jock.start();
    }
}
